package first.codeTop.byteDance;

/**
 * @ClassName LC101
 * @description:
 * @author: 荣燊
 * @create: 2021-10-21 21:18
 **/
public class LC101 {
    // 对称二叉树

    public boolean isSymmetric(TreeNode root) {
       return isAverage(root.left, root.right);
    }

    public boolean isAverage(TreeNode leftNode, TreeNode rightNode) {
        if (leftNode == null && rightNode == null) {
            return true;
        }
        if (leftNode == null || rightNode == null) {
            return false;
        }
        return (leftNode.val==rightNode.val) && isAverage(leftNode.left, rightNode.right)
                && isAverage(leftNode.right, rightNode.left);
    }
}
